<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
	<head>
		<title>个人中心－违规记录</title>
	</head>
	<body>
	
		<!-- self_info -->
		<div class="grzxbj">
			<div class="selfinfo center">
				<div class="lfnav fl">
					<div class="ddzx">违规记录</div>
					<div class="subddzx">
						<ul>
							<li><a href="${pageContext.request.contextPath}/toMy/sell">出售中的商品</a></li>
							<li><a href="${pageContext.request.contextPath}/toMy/tradingSuccess">已出售的商品</a></li>
							<li><a href="${pageContext.request.contextPath}/toMy/trading">交易中的商品</a></li>
							<li><a href="${pageContext.request.contextPath}/toMy/shelves">已下架的商品</a></li>
						</ul>
					</div>
					<div class="ddzx">个人中心</div>
					<div class="subddzx">
						<ul>
							<li><a href="${pageContext.request.contextPath}/toMy/my">我的资料</a></li>
							<li><a href="${pageContext.request.contextPath}/toMy/notice">消息通知</a></li>
							<li><a href="${pageContext.request.contextPath}/toMy/rMessage">收到的留言</a></li>
							<li><a href="${pageContext.request.contextPath}/toMy/sMessage">发布的留言</a></li>
							<li><a href="${pageContext.request.contextPath}/toMy/criminalRecords" style="color:#ff6700;font-weight:bold;">违规记录</a></li>
							<li><a href="${pageContext.request.contextPath}/toMy/report">举报记录</a></li>
						</ul>
					</div>
				</div>
				<div class="rtcont fr">
					<div class="grzlbt ml40">
						违规记录
						<span id="level-tooltip" data-toggle="tooltip" data-placement="right" title="&nbsp"></span>
					</div>
					<c:if test="${pagerModel.dates[0] != '' && pagerModel.dates[0] != null}">
						<c:forEach items="${pagerModel.dates}" var="criminalRecordslist" varStatus="status">
							<div class="panel panel-default cr-mar40">
								<div class="panel-heading cr-title">
									<span class="cr-type"><span>【违规类型】</span>${criminalRecordslist.criminalRecordsType}</span>
									<span class="cr-level" id="cr-level-${status.count}"></span>
									<span class="cr-time">${criminalRecordslist.criminalRecordsTime}</span>
									<input type="hidden" value="${criminalRecordslist.criminalRecordsLevel}">
								</div>
								<div class="panel-body cr-content">
									<span>【处理结果】</span>
									<input type="hidden" value="${criminalRecordslist.criminalRecordsId}">
									<a class="layui-btn" href="javascript:void(0)" title="点击查看详细">
										${criminalRecordslist.criminalRecordsContent}
									</a>
								</div>
							</div>
						</c:forEach>
						<jsp:include page="../page/page.jsp">
							<jsp:param name="url" value="${pageContext.request.contextPath}/toMy/criminalRecords"/>
							<jsp:param name="items" value="${pagerModel.totalSize}"/>
							<jsp:param name="maxPageItems" value="${pagerModel.messagePageSize}"/>
						</jsp:include>
					</c:if>
					
					<c:if test="${pagerModel.dates[0] == '' || pagerModel.dates[0] == null}">
						<div class="null_tishi">
							<img src="${pageContext.request.contextPath}/static/image/null_level.gif">
							<p id="autoText">一次违规记录都没有…</p>
						</div>
					</c:if>
				</div>
				<div class="clear"></div>
			</div>
		</div>
		
		<!-- 违规记录详细模态框 -->
		<div class="modal fade" id="show-notice-modal" tabindex="-1" role="dialog">
		  <div class="modal-dialog" role="document">
		    <div class="modal-content">
		      <div class="modal-header">
		        <h4 class="modal-title">标题</h4>
		      </div>
		      <div class="modal-body">
		        <p></p>
		        <span class="notice-time-span"></span>
		      </div>
		      <div class="modal-footer">
		        <button type="button" class="btn btn-default" id="notice-close-btn" data-dismiss="modal">关闭</button>
		      </div>
		    </div><!-- /.modal-content -->
		  </div><!-- /.modal-dialog -->
		</div><!-- 违规记录详细模态框 -->
		
		<script type="text/javascript">
			$(document).ready(function(){
				
				//工具提示
				$('#level-tooltip').tooltip('show');
				
				//查询非常严重违规次数
				$.ajax({
					url: "${pageContext.request.contextPath}/toMy/levelTimes",
					type: "POST",
					dataType: "JSON",
					success: function(data){
						$("#level-tooltip").siblings("div").children(".tooltip-inner").html("提示：您已严重违规 <b>" + data.levelTimes +"</b> 次，'严重违规'次数达到 <b>5</b> 次时，账号将被封停。");
					},
					error: function(a, b, c){
						layer.msg('查询非常严重违规次数失败');
					}
				});
				
				//评分
				layui.use('rate', function(){
				    var rate = layui.rate;
				    //给每一条记录添加一个评分
				    for(var i = 0; i < $(".cr-mar40 .cr-level").length; i++){
				    	var id = $($(".cr-mar40 .cr-level")[i]).attr("id");
				    	var level = $($(".cr-mar40 .cr-level")[i]).siblings("input[type='hidden']").val(); //获取记录的评分程度
				    	var levelVal = 0; //评分初始值
				    	if(level == "一般"){ //评分程度为一般时，评分初始值为1
				    		levelVal = 1;
				    	}else if(level == "轻"){//评分程度轻时，评分初始值为2
				    		levelVal = 2;
				    	}else if(level == "严重"){//评分程度严重时，评分初始值为3
				    		levelVal = 3;
				    	}else if(level == "非常严重"){//评分程度非常严重时，评分初始值为4
				    		levelVal = 4;
				    	}
				    	//渲染
					    var ins1 = rate.render({
					      elem: '#' + id,  //绑定元素
					      length: 4, //星星数量
						  value: levelVal, //评分初始值
						  text: true, //显示对应评分内容
						  readonly: true, //设置只读状态
						  theme: '#FE0000', //颜色
					      setText: function(value){ //自定义文本
					    	    var arrs = {
					    	      '1': '一般',
					    	      '2': '轻',
					    	      '3': '严重',
					    	      '4': '非常严重'
					    	    };
					    	    this.span.text(arrs[value]);
					    	  }
					      
					    });
				    }
				    
				});
				
				//点击查看违规记录详细
				$(".cr-mar40 .cr-content a[class='layui-btn']").on("click", function(){
					$("#show-notice-modal .modal-body p").html("<img src='${pageContext.request.contextPath}/static/image/loading.gif' style='margin-left:45%;'>加载中…");
					$("#show-notice-modal").modal("show");
					var levelId = $(this).siblings("input[type='hidden']").val();
					$.ajax({
						url: "${pageContext.request.contextPath}/toMy/getCriminalRecordsById",
						type: "POST",
						dataType: "JSON",
						data: {
							"levelId": levelId,
						},
						success: function(data){
							var res = data.cshtCriminalRecords;
							$("#show-notice-modal .modal-title").text("【" + res.criminalRecordsType + "】");
							$("#show-notice-modal .modal-body p").html(res.criminalRecordsContent + "<br/><b style='font-weight:bolder'>(违规程度：<b style='color:#FF5722'>" + res.criminalRecordsLevel + "</b>)</b>");
							$("#show-notice-modal .modal-body span").text(res.criminalRecordsTime);
						},
						error: function(a, b, c){
							layer.msg('查询出错');
						}
					})
				});
				
				/*跳跳字体动画
				 *  参数详解:
				 *	upTime			上移的时间
				 *	downTime		下落的时间
				 *	beatHeight		上移高度
				 *	isAuth			是否自动
				 *	isRotate		是否旋转
				*/
				$('p#autoText').beatText({isAuth:true,beatHeight:"1.5em",isRotate:false});

			})
		</script>
		
		
	</body>
</html>